<Button
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:loc="clr-namespace:Peer2PeerControlLibraryWPF.VisualStudio.Design" 
	x:Class="Peer2PeerControlLibraryWPF.VisualStudio.Design.BouncyButton"
	x:Name="UserControlSelf"
  x:ClassModifier="internal"
  >

  <Button.Template>
    <ControlTemplate TargetType="Button">
      <Grid 
        x:Name="_grid"
        Width="{TemplateBinding Property=Width}"
        Height="{TemplateBinding Property=Height}">

        <Grid.Resources>

          <Storyboard x:Key="ExpandAnimation" BeginTime="0:0:0">
            <DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="_grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)">
              <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.1"/>
              <SplineDoubleKeyFrame KeySpline="0.5,0,0.5,1" KeyTime="00:00:00.4" Value="1.4"/>
              <SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,1" KeyTime="00:00:01" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="_grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)">
              <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.1"/>
              <SplineDoubleKeyFrame KeySpline="0.5,0,0.5,1" KeyTime="00:00:00.6" Value="1.4"/>
              <SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,1" KeyTime="00:00:01" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
          </Storyboard>

        </Grid.Resources>

        <Grid.Triggers>
          <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource ExpandAnimation}"/>
          </EventTrigger>
        </Grid.Triggers>
        
        <Grid.RenderTransform>
          <ScaleTransform ScaleX="1" ScaleY="1"/>
        </Grid.RenderTransform>

        <Ellipse 
          Fill="{TemplateBinding Property=Background}"
          Stroke="#FF000000"
          StrokeThickness="2"/>
        
        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Property=Button.Content}"/>

        <Ellipse>
          <Ellipse.Fill>
            <RadialGradientBrush>
              <RadialGradientBrush.RelativeTransform>
                <TransformGroup>
                  <ScaleTransform ScaleX="0.914" ScaleY="0.819"/>
                </TransformGroup>
              </RadialGradientBrush.RelativeTransform>
              <GradientStop Color="#00000000" Offset="0.628"/>
              <GradientStop Color="#00000000" Offset="1"/>
            </RadialGradientBrush>
          </Ellipse.Fill>
        </Ellipse>

      </Grid>
    </ControlTemplate>
  </Button.Template>
</Button>
